


<?= HTML::style('static/bootstrap-3.3.7/css/bootstrap-datepicker.css')?>

<h3 class="page-header">添加项目设备  &nbsp; &nbsp;<span id="add">+</span> &nbsp; &nbsp; <span id="del">-</span></h3>
<form action="<?php URL::curr()?>"  method="post" class="form-horizontal">
	<div class="row">
		
    	<div class="col-sm-3">
        	
        	
        	
        	<div class="form-group">
        		<label class="col-sm-4 control-label">设备</label>
        		<div class="col-sm-8">
            		<select class="form-control" name="device_id[]">
            		<option value="0"> -选择设备- </option>
            		<?php foreach ($deviceInfo as $item):?>
            		<option value="<?= $item['id'] ?>"> <?= $item['name'] ?> </option>
            		<?php endforeach;?>
                    </select>
                </div>
        	</div>

        	
        	<div class="form-group">
        		<label class="col-sm-4 control-label">租赁价格</label>
        		<div class="col-sm-8">
            		<input class="form-control" type="text" name="price[]" value="" required >
                </div>
        	</div>
        	
        	<div class="form-group">
        		<label class="col-sm-4 control-label">开始日期</label>
        		<div class="col-sm-8">
					<input type="text" class='form-control selectData' id='startDate' name='s_time[]' required  > 
				</div>
        	</div>
        	
        	
        	<div class="form-group">
        		<label class="col-sm-4 control-label">结束日期</label>
        		<div class="col-sm-8">
        			<input type="text" class='form-control selectData' id='startDate' name='e_time[]' required  >
        		</div>
        	</div>
        	
        	
        	
		</div>
		
	</div>
	<div class="form-group">
		<div class="col-sm-offset-1 col-sm-3">
			<button type="submit" class="btn btn-primary">提交</button>
		</div>
	</div>		
</form>

<?= HTML::script('static/bootstrap-3.3.7/js/bootstrap-datepicker.js')?>

<script>




$.fn.datepicker.dates['cn'] = {   //切换为中文显示  
        days: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],  
                daysShort: ["日", "一", "二", "三", "四", "五", "六", "七"],  
                daysMin: ["日", "一", "二", "三", "四", "五", "六", "七"],  
                months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],  
                monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],  
                today: "今天",  
                clear: "清除"  
    };  
  
     $('.selectData').datepicker({  
        autoclose: true, //自动关闭  
        beforeShowDay: $.noop,    //在显示日期之前调用的函数  
        calendarWeeks: false,     //是否显示今年是第几周  
        clearBtn: false,          //显示清除按钮  
        daysOfWeekDisabled: [],   //星期几不可选  
        endDate: Infinity,        //日历结束日期  
        forceParse: true,         //是否强制转换不符合格式的字符串  
        format: 'yyyy-mm-dd',     //日期格式  
        keyboardNavigation: true, //是否显示箭头导航  
        language: 'cn',           //语言  
        minViewMode: 0,  
        orientation: "bottom",      //方向  
        rtl: false,  
        startDate: -Infinity,     //日历开始日期  
        startView: 0,             //开始显示  
        todayBtn: false,          //今天按钮  
        todayHighlight: true,    //今天高亮  
        weekStart: 0              //星期几是开始  
    }); 


 


	var  str=`<div class="col-sm-3">
	
	<div class="form-group">
		<label class="col-sm-4 control-label">设备</label>
		<div class="col-sm-8">
    		<select class="form-control" name="device_id[]">
    		<option value="0"> -选择设备- </option>
    		<?php foreach ($deviceInfo as $item):?>
    		<option value="<?= $item['id'] ?>"> <?= $item['name'] ?> </option>
    		<?php endforeach;?>
            </select>
        </div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-4 control-label">租赁价格</label>
		<div class="col-sm-8">
    		<input class="form-control" type="text" name="price[]" value="" required >
        </div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-4 control-label">开始日期</label>
		<div class="col-sm-8">
			<input type="text" class='form-control selectData' id='startDate' name='s_time[]' required  > 
		</div>
	</div>
	
	
	<div class="form-group">
		<label class="col-sm-4 control-label">结束日期</label>
		<div class="col-sm-8">
			<input type="text" class='form-control selectData' id='startDate' name='e_time[]' required  >
		</div>
	</div>
	
	
	
</div>`

	$("#add").click(function(){
		$(".row").append(str);
		$.fn.datepicker.dates['cn'] = {   //切换为中文显示  
		        days: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],  
		                daysShort: ["日", "一", "二", "三", "四", "五", "六", "七"],  
		                daysMin: ["日", "一", "二", "三", "四", "五", "六", "七"],  
		                months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],  
		                monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],  
		                today: "今天",  
		                clear: "清除"  
		    };  
		  
		     $('.selectData').datepicker({  
		        autoclose: true, //自动关闭  
		        beforeShowDay: $.noop,    //在显示日期之前调用的函数  
		        calendarWeeks: false,     //是否显示今年是第几周  
		        clearBtn: false,          //显示清除按钮  
		        daysOfWeekDisabled: [],   //星期几不可选  
		        endDate: Infinity,        //日历结束日期  
		        forceParse: true,         //是否强制转换不符合格式的字符串  
		        format: 'yyyy-mm-dd',     //日期格式  
		        keyboardNavigation: true, //是否显示箭头导航  
		        language: 'cn',           //语言  
		        minViewMode: 0,  
		        orientation: "bottom",      //方向  
		        rtl: false,  
		        startDate: -Infinity,     //日历开始日期  
		        startView: 0,             //开始显示  
		        todayBtn: false,          //今天按钮  
		        todayHighlight: true,    //今天高亮  
		        weekStart: 0              //星期几是开始  
		    }); 
				
	})
	$("#del").click(function(){
		if($(".row .col-sm-3").length>1){
			$(".row .col-sm-3:nth-last-child(1)").remove();
		}
	})
	
	

</script>